package com.example.whopxx;

import com.example.whopxx.dao.UserDao;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "DeleteServlet", value = "/DeleteServlet")
public class DeleteServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html;charset=utf-8");
        String id = request.getParameter("id");
        if(!id.equals("")){
            UserDao userDao = new UserDao();
            PrintWriter out = response.getWriter();
            out.println("<html><body>");
            if (userDao.deleteUserById(id)) {
                out.println("<h1>删除成功！</h1>");

            } else {
                out.println("<h1>删除失败！</h1>");
            }
            out.println("<a href='IndexServlet'>返回</a>");
            out.println("</body></html>");
        }
    }
}
